/******************************************************************************
* File description: errormessage.qml
* Function: 错误信息页
* Current Version: 1.0.0
* Author: 张宇轩
* Date: 2024-08-27
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import QtGraphicalEffects 1.14
import SvgImage 1.0

Item {
    id: root

    /* property 定义开始 */
    // 错误信息
    property string error: "222233333333333333333333333333333333333333333333333 33333333333"
    property url errIconPath: "qrc:/icons/error_msg.svg"
    // 解决方案
    property string suggestions: "222233333333333333333333333333333333333333333333333 33333333333"
    property url suggIconPath: "qrc:/icons/suggestions.svg"
    /* property 定义结束 */

    // 顶部导航栏
    TabbarNav {
        id: tabNav
        width: parent.width
        isEnable: true
        title: "故障信息"

        onReturnSig: {
            console.log("tabbar nav")
        }
        z: 999
    }

    ColumnLayout {
        anchors.fill: parent
        spacing: 0

        // 主体部分
        Rectangle {
            id: mainPart
            Layout.fillWidth: true
            Layout.preferredHeight: parent.height - btnContainer.height
            Layout.alignment: Qt.AlignTop

            // 背景
            Rectangle {
                anchors.fill: parent
                LinearGradient {
                    anchors.fill: parent
                    start: Qt.point(0, 0)
                    end: Qt.point(0, height)
                    gradient: Gradient {
                        GradientStop {position: 0.0; color: "#007BD8"}
                        GradientStop {position: 1.0; color: "#001A5A"}
                    }
                }
            }

            // 容器
            Rectangle {
                id: errMsgContainer
                anchors {
                    fill: parent
                    leftMargin: 212
                    rightMargin: 212
                    topMargin: 95 + tabNav.height
                    bottomMargin: 150
                }
                color: "#C3FFFFFF"
                radius: 12

                ColumnLayout {
                    anchors {
                        fill: parent
                        leftMargin: 31
                        rightMargin: 43
                        topMargin: 33
                    }
                    spacing: 40

                    // 故障信息
                    Item {
                        id: errorMsgCon
                        Layout.fillWidth: true
                        Layout.fillHeight: true

                        ColumnLayout {
                            anchors.fill: parent
                            spacing: 15

                            // 故障标题
                            Item {
                                Layout.fillWidth: true
                                implicitHeight: Math.max(errIcon.height, errTitle.implicitHeight)

                                // 图标
                                Item {
                                    id: errIcon
                                    width: 23
                                    height: 23
                                    anchors.verticalCenter: parent.verticalCenter

                                    SvgImage {
                                        anchors.fill: parent
                                        source: root.errIconPath
                                    }
                                }

                                // 标题
                                Label {
                                    id: errTitle
                                    width: parent.width
                                    anchors.left: errIcon.right
                                    anchors.leftMargin: 15
                                    font.pixelSize: 20
                                    color: "#FF222222"
                                    text: "故障信息"
                                }
                            }

                            // 故障信息
                            Label {
                                id: errMsg
                                Layout.fillWidth: true
                                font.pixelSize: 20
                                color: "#FF222222"
                                text: root.error
                                clip: true
                                wrapMode: Text.Wrap
                            }

                            CustomVerSpacerItem {}
                        }
                    }


                    // 解决方案
                    Item {
                        id: suggestionsCon
                        Layout.fillWidth: true
                        Layout.fillHeight: true

                        ColumnLayout {
                            anchors.fill: parent
                            spacing: 15

                            // 解决方案标题
                            Item {
                                Layout.fillWidth: true
                                implicitHeight: Math.max(suggestionsIcon.height, suggestionsTitle.implicitHeight)

                                // 图标
                                Item {
                                    id: suggestionsIcon
                                    width: 20
                                    height: 20
                                    anchors.verticalCenter: parent.verticalCenter

                                    SvgImage {
                                        anchors.fill: parent
                                        source: root.suggIconPath
                                    }
                                }

                                // 标题
                                Label {
                                    id: suggestionsTitle
                                    width: parent.width
                                    anchors.left: suggestionsIcon.right
                                    anchors.leftMargin: 15
                                    font.pixelSize: 20
                                    color: "#FF222222"
                                    text: "解决方案"
                                }
                            }

                            // 解决方案
                            Label {
                                id: suggestionsMsg
                                Layout.fillWidth: true
                                font.pixelSize: 20
                                color: "#FF222222"
                                text: root.suggestions
                                clip: true
                                wrapMode: Text.Wrap
                            }

                            CustomVerSpacerItem {}
                        }
                    }
                    CustomVerSpacerItem {}
                }

            }
        }

        // 按钮部分
        Rectangle {
            id: btnContainer
            Layout.fillWidth: true
            Layout.preferredHeight: 80

            RowLayout {
                height: parent.height
                anchors.rightMargin: 16
                anchors.right: parent.right

                PureButton {
                    id: canceledBtn
                    pureText: "取消(C)"
                    Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
                }

                GradientButton {
                    id: stopExperimentBtn
                    gradText: "停止实验(F)"
                    Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
                }
            }
        }
    }
}
